#include "txtframe.h"
#include <wx/wx.h>

TextFrame::TextFrame(const wxChar* title, int xpos, int ypos, int width, int height)
	: wxFrame(NULL, -1, title, wxPoint(xpos, ypos), wxSize(width, height)){
		// 创建TextCtrl控件
		_pTextCtrl = new wxTextCtrl(this, -1, wxString("Type some text here..."), wxDefaultPosition, wxDefaultSize);

		// 创建菜单栏
		_pMenuBar = new wxMenuBar();

		_pFileMenu = new wxMenu();
		_pFileMenu->Append(MENU_FILE_OPEN, "&Open");
		_pFileMenu->Append(MENU_FILE_SAVE, "&Save");
		_pFileMenu->Append(MENU_FILE_QUIT, "&Quit");

		_pInfoMenu = new wxMenu();
		_pInfoMenu->Append(MENU_INFO_ABOUT, _T("&关于"));

		_pMenuBar->Append(_pFileMenu, _T("&文件"));
		_pMenuBar->Append(_pInfoMenu, _T("&信息"));

		SetMenuBar(_pMenuBar);

		// 创建状态栏
		CreateStatusBar(3);
		SetStatusText("This is a test.", 0);
	}

TextFrame::~TextFrame(){ }

BEGIN_EVENT_TABLE(TextFrame, wxFrame)
	EVT_MENU(MENU_FILE_OPEN, TextFrame::OnMenuFileOpen)
	EVT_MENU(MENU_FILE_SAVE, TextFrame::OnMenuFileSave)
	EVT_MENU(MENU_FILE_QUIT, TextFrame::OnMenuFileQuit)
	EVT_MENU(MENU_INFO_ABOUT, TextFrame::OnMenuInfoAbout)
END_EVENT_TABLE()

void TextFrame::OnMenuFileOpen(wxCommandEvent &event){
	wxLogMessage(_T("Clicked File-Open Menu."));
}

void TextFrame::OnMenuFileSave(wxCommandEvent &event){
	wxLogMessage(_T("Clicked File-Save Menu."));
}

void TextFrame::OnMenuFileQuit(wxCommandEvent &event){
	wxLogMessage(_T("Clicked File-Quit Menu."));
}

void TextFrame::OnMenuInfoAbout(wxCommandEvent &event){
	wxLogMessage(_T("Clicked Info-About Menu."));
}

